/*
============================================================================
 Name        : BlockPicHis.h
 Author      : \x{738b}\x{658c}
 Version     :
 Copyright   : \x{76ca}\x{76df}\x{8f6f}\x{4ef6}
 Description : CBlockPicHis declaration
============================================================================
*/

#ifndef BLOCKPICHIS_H
#define BLOCKPICHIS_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "BlockPic.h"

// CLASS DECLARATION

/**
*  CBlockPicHis
* 
*/

class CInd_MA;
class CInd;

class THisDay
{
public:
	TInt m_nTime;
	TInt m_nOpen;
	TInt m_nHigh;
	TInt m_nLow;
	TInt m_nClose;
	TInt8 m_bBS;

	TInt m_pnMA[4];
	TInt64 m_plInd[4];
	THisDay()
	{
		m_nTime = 0;
		m_nOpen = 0;
		m_nHigh = 0;
		m_nLow = 0;
		m_nClose = 0;
		m_bBS = 0;
		for (TInt i =0; i < 4; i++)
			m_pnMA[i] = 0;
		for (TInt i =0; i < 4; i++)
			m_plInd[i] = 0;
	};
};


class CBlockPicHis : public CBlockPic
{
public:
	~CBlockPicHis();

	static CBlockPicHis* NewL(CBaseBlock* bsBack);

	static CBlockPicHis* NewLC(CBaseBlock* bsBack);

	CBlockPicHis(CBaseBlock* bsBack);

public:
	//new functions
	void CalcTB()const;
	
	void Time2String(TDes& aDes,const TInt32& nTime)const;

	void DrawCheck(CFbsBitGc& g)const;

	void OnDraw(CFbsBitGc& g)const;

	TInt Pos2X(const TInt32& nPos)const;

	void OnKeyDown(TInt keyCode);

	void OnMouseDown(const TPoint& aPt);

	void OnMouseUp(const TPoint& aPt);
	
	TBool HandleGesture(const TGestureType& aGesture);

	void OnInput(const TDesC8& strInput);

	void InitData();

	void InitDataInd();

	void CalcMM(TBool bCreateLR);

	TInt32 GetMenuItem();

	TBool ReadData(const TDesC8& aData);

	void WriteData(TDes8& aBuf);

	TInt GetDataLength();

	TInt16 GetDataType();

	void SetIndType(const TInt8&  bIndType);
	
	TInt GetDataSize()const;

	virtual void SetGoods(TInt nGoodsID);

	virtual void SetGoods(const TGoods& goods);

	virtual TBool OnMenuEvent(TInt menuId);

	virtual void SizeChanged();

	void ResetDay();

	TInt FindDay(const THisDay& dayNew);

	TInt ChangeDay(const THisDay& dayNew);
	
	void ReSetFocus();

	void ChangeFocus(TBool aFoucs, const TInt& keyCode);
	
	TRect GetGestureRect();
	
	void RevolveScreen();

private:
	void ConstructL();

	void CheckOpenFund();

	void DrawKLine(CFbsBitGc& g, THisDay day, TInt nX, TInt nW,
		TInt nYOpen, TInt nYHigh, TInt nYLow, TInt nYClose) const;

	void DrawCPXLine(CFbsBitGc& g, THisDay day, TInt nX, TInt nW,
		TInt nYOpen, TInt nYHigh, TInt nYLow, TInt nYClose) const;

	void DrawGoodInfo(CFbsBitGc& g, TInt32 aTime, TInt aPosX) const;//\x{6709}\x{4e2a}\x{80a1}\x{8d44}\x{8baf}\x{65f6}\x{7ed8}*\x{53f7}

	void DrawOverTimeTipString(CFbsBitGc& g, TRect aRect, TInt pos) const;

	void GoToGoodInfo();

	void InitSwitchPeriodMenu();

	void InitSwitchIndexMenu();

public:
	RArray<THisDay> m_vDay;
	RArray<TGoodInfo> m_InfoArray;
	TInt m_nWidthPerDay;
	TInt m_nWidthPerDayMin;
	TInt8 m_bDataType;
	TInt32 m_nKLineType;
	CInd_MA* m_indMA;//1
	TInt8 m_bIndType;
	CInd* m_pInd;//2
	TInt8 m_bOpenFund;
	TInt m_pnFirstMA[3];
	TInt m_pnFirstInd[4];
	TInt m_nDateFirstInd;
	TInt m_nDateLastInd;

	TInt BSInd_time;//20100830\x{7248}\x{672c}\x{9700}\x{6c42}\x{ff1a}\x{8fc7}\x{671f}\x{7684}\x{53f7}\x{ff0c}\x{8fd1}N20\x{4e2a}\x{5468}\x{671f}\x{64cd}\x{76d8}\x{7ebf}\x{4e3a}K\x{7ebf}

	TBool iRequestOverTimeTip;
	enum {UP, DOWN};
	HBufC* 	iStrOverTimeTip;
	TInt iTipType;

	mutable TRect iSwitchPeriodRect;
	mutable TRect iSwitchIndexRect;
	TBool iSwitchPeriodFocus;
	TBool iSwitchIndexFocus;
	CPopMenu* iSwitchPeriodMenu;
	CPopMenu* iSwitchIndexMenu;
};

#endif // BLOCKPICHIS_H
